package com.tsunami.auth.controller;

import com.tsunami.auth.service.auth.IRoleService;
import com.tsunami.authority.entity.auth.Role;
import com.tsunami.base.R;
import com.tsunami.user.annotation.LoginUser;
import com.tsunami.user.model.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Classname TestController
 * @Description TODO
 * @Date 2021-10-20 17:36
 * @Created by lx
 */
@RequestMapping("/auth/test")
@RestController
@Api(tags = "测试控制器",value = "TestController")
public class TestController {

    @Autowired
    IRoleService roleService;

    @GetMapping("info")
    @ApiOperation(notes = "用户获取角色",value = "用户角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Long", paramType = "query")
    })
    public R roleInfo(@LoginUser SysUser user){
        List<Role> roleList = roleService.findRoleByUserId(user.getId());
        return R.ok().data(roleList);
    }
}
